package com.my12306.train.controller;

import com.my12306.common.model.vo.PageVo;
import com.my12306.common.util.PageUtils;
import com.my12306.common.util.response.ResponseData;
import com.my12306.train.model.entity.RateEntity;
import com.my12306.train.model.vo.RateVO;
import com.my12306.train.service.RateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 票种的票率
 *
 * @author ËÕÄÁÏ¦
 */
@RestController
@RequestMapping("/ticket/rate")
public class RateController {
    @Autowired
    private RateService rateService;

    /**
     * 列表
     */
    @PostMapping("/lst")
    public ResponseData list(@RequestBody PageVo pageVo) {
        PageUtils page = rateService.queryTicketRateByPage(pageVo);
        return ResponseData.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/inf/{id}")
    public ResponseData info(@PathVariable("id") Long id) {
        RateEntity rate = rateService.queryTicketRateById(id);
        return ResponseData.ok().put("rate", rate);
    }
  class GirlFriend{
        private  Double cupSize;
        private Integer size;

  }
    /**
     * 保存
     */
    @PostMapping("/sv")
    public ResponseData save(@Validated @RequestBody RateVO rateVO) {
     return rateService.saveTickRate(rateVO);
    }

    /**
     * 修改
     */
    @PutMapping("/up")
    public ResponseData update(@RequestBody RateEntity rate) {
        rateService.updateTicketRateById(rate);
        return ResponseData.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/del")
    public ResponseData delete(@RequestBody List<Long> ids) {
        rateService.removeTicketRateByIds(ids);
        return ResponseData.ok();
    }

}
